//
//  TJTitleTextField.m
//  BaoDian
//
//  Created by mac on 2024/7/17.
//

#import "TJTitleTextField.h"

 
@interface TJTitleTextField()<QMUITextFieldDelegate>

 

@end



@implementation TJTitleTextField


- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        
        UILabel *lengthLabel = [UILabel lableWithSuperView:self font:UIFontMake(14) color:UIColor.tj_8D9298Color title:nil textAlignment:NSTextAlignmentCenter];
        [lengthLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.right.offset(0);
            make.width.offset(12);
        }];

        UIView *textFieldContentView = [UIView addToView:self];
        textFieldContentView.addCornerRadius(10);
        [textFieldContentView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(0);
            make.right.equalTo(lengthLabel.mas_left);
             make.top.bottom.offset(0);
        }];
        
        UILabel *titleLabel = [UILabel lableWithSuperView:textFieldContentView font:UIFontMake(14) color:UIColor.tj_868391Color title:nil textAlignment:NSTextAlignmentLeft];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.left.offset(20);
        }];
 
        QMUITextField *textField = [QMUITextField addToView:textFieldContentView];
        textField.font = UIFontMake(14);
        textField.delegate = self;
        textField.returnKeyType = UIReturnKeyDone;
        textField.textColor = UIColor.whiteColor;
        textField.placeholderColor = UIColor.tj_placeholderTextColor;
        [textField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(100);
            make.right.offset(0);
            make.top.bottom.offset(0);
        }];
 
        _titleLabel = titleLabel;
        _textField = textField;
        _lengthLabel = lengthLabel;
     }
    return self;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    return YES;
}

 
- (void)setSecureTextEntry:(BOOL)secureTextEntry {
    _secureTextEntry = secureTextEntry;
    
    _textField.secureTextEntry = secureTextEntry;
 
}
 
@end
